/**
 * Created by Administrator on 2017/4/16.
 */
!(function($){
    var type = $('#type_type').val();
    var categoryId = $('#type_categoryId').val();
    var from = $('#type_from').val();
    var orderBy = 0;
    var params = {
        type:type,
        categoryId:categoryId,
        from:from,
        orderBy:0
    };

    var home = {
        init:function(){
            this.loadData();
            this.getServices();
            filter();
            getCateogrys(0);
            getCategoryList(type,orderBy,categoryId);
            dropLoad.init(params);
            loadNav();

        },
        /**
         * slider模块加载
         */
        loadData:function(){
            $.ajax({
                url:API_URL+GET_HOME_INFOS_URL,
                type:'get',
                dataType:'jsonp',
                success:function(data){
                    if(data.ok == true){
                        var datas = data.result;
                        var tpl = template('slider_tpl',datas);
                        $('#slider').empty().html(tpl);
                        new Swiper('#slider .swiper-container', {
                            pagination: '#slider .swiper-pagination',
                            paginationClickable :true
                        });
                    }
                },
                error:function(data){
                    $.toptips(data.msg);
                }
            })
        },
        getServices:function(){
            $.ajax({
                url:API_URL+GET_SERVICES_URL,
                type:'post',
                dataType:'jsonp',
                success:function(data){
                    var arr = data.result;
                    if(arr.length>0){
                        var tpl = template('services_tpl',data);
                        $('.nav-7').html(tpl);
                    }
                },
                error:function(data){
                    $.toptips(data.msg);
                }
            })
        }

    };
    $(function(){
        home.init();

    })
})(Zepto);